package com.guc.coroutines.animator

import android.animation.TypeEvaluator
import android.graphics.Point
import android.util.Log
import kotlin.math.sin


/**
 * Created by guc on 2021/9/22.
 * Description：属性动画自定义实现
 *              TypeEvaluator 确定运动轨迹
 */
class PointSinEvaluator : TypeEvaluator<Point> {
    override fun evaluate(fraction: Float, startValue: Point, endValue: Point): Point {
        val x: Float = startValue.x + fraction * (endValue.x - startValue.x)
        val y: Float = (sin(x * Math.PI / 180) * 100).toFloat() + endValue.y / 2
        return Point(x.toInt(), y.toInt())
    }
}